package com.ruoyi.develop.factory.factoryProduceWork.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.develop.factory.factoryProduceWork.domain.FactoryProduceWork;
import com.ruoyi.develop.factory.factoryProduceWork.service.IFactoryProduceWorkService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工单信息Controller
 * @author qh
 * @date 2024-11-06
 */
@RestController
@RequestMapping("/factoryProduceWork/factoryProduceWork")
public class FactoryProduceWorkController extends BaseController {
    @Autowired
    private IFactoryProduceWorkService factoryProduceWorkService;

    /**
     * 查询工单信息列表
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryProduceWork:query')")
    @GetMapping("/list")
    public TableDataInfo list(FactoryProduceWork entity) {
        startPage();
        List<FactoryProduceWork> list = factoryProduceWorkService.selectList(entity);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('develop:FactoryProduceWork:query')")
    @GetMapping("/listByPlan")
    public TableDataInfo listByPlan(FactoryProduceWork entity) {
        startPage();
        List<FactoryProduceWork> list = factoryProduceWorkService.listByPlan(entity);
        return getDataTable(list);
    }
    /**
     * 导出工单信息列表
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryProduceWork:export')")
    @Log(title = "工单信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FactoryProduceWork entity) {
        List<FactoryProduceWork> list = factoryProduceWorkService.selectList(entity);
        ExcelUtil<FactoryProduceWork> util = new ExcelUtil<FactoryProduceWork>(FactoryProduceWork. class);
        util.exportExcel(response, list, "工单信息数据");
    }

    /**
     * 获取工单信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryProduceWork:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(factoryProduceWorkService.selectById(id));
    }

    /**
     * 新增工单信息
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryProduceWork:add')")
    @Log(title = "工单信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody FactoryProduceWork entity) {
        return toAjax(factoryProduceWorkService.insert(entity));
    }

    /**
     * 修改工单信息
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryProduceWork:edit')")
    @Log(title = "工单信息", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody FactoryProduceWork entity) {
        return toAjax(factoryProduceWorkService.update(entity));
    }

    /**
     * 删除工单信息
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryProduceWork:remove')")
    @Log(title = "工单信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(factoryProduceWorkService.deleteByIds(ids));
    }
}
